<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="de.laures.cewolf.ChartPostProcessor"%>
<%@page import="java.awt.*" %>
<%@page import="java.util.*"%>
<%@page import="de.laures.cewolf.*"%>
<%@page import="de.laures.cewolf.cpp.*"%>
<%@page import="de.laures.cewolf.example.*"%>
<%@page import="de.laures.cewolf.links.*"%>
<%@page import="de.laures.cewolf.taglib.CewolfChartFactory" %>
<%@page import="de.laures.cewolf.tooltips.*"%>
<%@page import="org.jfree.chart.*"%>
<%@page import="org.jfree.chart.event.ChartProgressEvent" %>
<%@page import="org.jfree.chart.event.ChartProgressListener" %>
<%@page import="org.jfree.chart.plot.*"%>
<%@page import="org.jfree.data.*"%>
<%@page import="org.jfree.data.category.*"%>
<%@page import="org.jfree.data.gantt.*"%>
<%@page import="org.jfree.data.general.*"%>
<%@page import="org.jfree.data.time.*"%>
<%@page import="org.jfree.data.xy.*"%>
<%@taglib uri="http://cewolf.sourceforge.net/taglib/cewolf.tld" prefix="cewolf" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/global.js"></script>
<script type="text/javascript" src="js/tooltip.js"></script>
<link type="text/css" href="style/cewolf.css" rel="stylesheet">
</head>
<body>
<jsp:useBean id="pageViews" class="de.laures.cewolf.example.LineData"/>
<%
DatasetProducer ganttData = new DatasetProducer() {
    final private long now = System.currentTimeMillis();
    final private long day = 1000 * 60 * 60 * 24;
    final private String[] workflows =
      { "Analysis", "Design", "Implementation", "Test", "Rollout", "Operations" };
    final private String[] person = { "Frank", "Paul", "Daisy", "Chris" };
    public Object produceDataset(Map params) {
      TaskSeriesCollection ds = new TaskSeriesCollection();
      for (int j = 0; j < 4; j++) {
        TaskSeries ser = new TaskSeries(person[j]);
        long lastEnd = now + getRandomTime();
        for (int i = 0; i < workflows.length; i++) {
          long myEnd = lastEnd + getRandomTime();
          Task t = new Task(workflows[i], new SimpleTimePeriod(new Date(lastEnd), new Date(myEnd)));
          ser.add(t);
          lastEnd = myEnd;
        }
        ds.add(ser);
      }
      return ds;
    }
    private long getRandomTime() {
      return day * (long) (Math.random() * 31 + 15);
    }
    public String getProducerId() {
      return "GanttDataProducer";
    }
    public boolean hasExpired(Map params, Date since) {
      return true;
    }
  };
  pageContext.setAttribute("ganttData", ganttData);
%>
<jsp:useBean id="dateAxisProcessor" class="de.laures.cewolf.cpp.DateAxisProcessor" />
<div>
<cewolf:chart id="gantt" title="Gantt" type="gantt" xaxislabel="Workflow">
    <cewolf:data>
        <cewolf:producer id="ganttData" />
    </cewolf:data>
   	<cewolf:chartpostprocessor id="dateAxisProcessor">
   		<cewolf:param name="type" value="range"/>
        <cewolf:param name="format" value="yyyy-MM"/>
        <cewolf:param name="tickUnit" value="MONTH"/>
        <cewolf:param name="tickStep" value="1"/>
    </cewolf:chartpostprocessor>
</cewolf:chart>
<cewolf:img chartid="gantt" renderer="/cewolf" width="800" height="400"/>
</div>
</body>
</html>